package com.wc.acwing.思维.密接牛追踪2;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2025/2/25 23:17
 * @description
 * https://www.acwing.com/problem/content/5441/
 */
public class Main {
    /**
     * 教学视频：https://www.acwing.com/video/5543/
     * 思路：
     * 贪心
     * 每一个连续的 1, 假设有 c 个 1,
     * 那么假设用了 r天感染,
     * 一个 1 r天感染 r * 2 + 1 <= c, 说明 r 最大就是 (c - 1) / 2, 并且 r越大越好, 说明剩下的 1 越少
     * 那一个堆里面最小有几个呢,
     * 也就是最少需要多少个 2 * r + 1 覆盖住
     * 显然是  c / (r * 2 + 1) 上取整
     *
     * r <= (c - 1) / 2 下取整, 一共有 m 个 c
     * 中间 r <= min((c - 1) / 2)
     * 边界 r <= c - 1
     *
     * 那么每个里面最小有多少个 1 呢
     *
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 300010;
    static char[] s = new char[N];
    static int[] cnt = new int[N];
    static int n;

    public static void main(String[] args) {
        n = sc.nextInt();
        s = (" " + sc.next()).toCharArray();
        int r = n, m = 0;
        for (int i = 1; i <= n; i++) {
            if (s[i] == '0') continue;
            int j = i;
            while (j <= n && s[j] == '1') j++;
            int c = j - i, d = (c - 1) / 2;
            // 这里注意 j = n + 1, 表示 s[n + 1] == '0'
            if (i == 1 || j == n + 1) d = c - 1;

            r = Math.min(r, d);
            cnt[++m] = c;
            i = j;
        }

        int res = 0;
        for (int i = 1; i <= m; i++) {
            res += (cnt[i] + 2 * r) / (2 * r + 1);
        }
        out.println(res);
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}

